<!doctype html>
<html lang="en-US">
<head>
	<meta charset="UTF-8" />
	<title>Congo Documentation</title>
	<link rel="stylesheet" type="text/css" href="pagestyle.css" />
</head>
<body>
	<div class="sheet container">
		<header class="main">

			<div class="title">
				<a href="Modules_congo.html"><img src="data/congo.png"/></a>Congo Documentation
			</div>

		</header>

		<div class="row content">
			<div class="span12">
			
				
<h1>Class <span class="name">Sprite</span></h1>


	<p>Main sprite class.
	<a href="#description"> More...</a></p>


<hr>

<table class="table scope-contents">
	
		<tr>
			<td class="span1 name">Extends:</td>
			<td>
				<ul class="unstyled">
					<li><a href="Modules_congo.displayitem_DisplayItem.html">DisplayItem</a></li>
				</ul>
			</td>
		</tr>
	
	
	
	
	
		<tr>
			<td class="span1 name">Extended&nbsp;by:</td>
			<td>
				<ul class="unstyled">
					<li><a href="Modules_congo.animatedsprite_AnimatedSprite.html">AnimatedSprite</a>, <a href="Modules_congo.menu_Menu.html">Menu</a>, <a href="Modules_congo.particleemitter_ParticleEmitter.html">ParticleEmitter</a>, <a href="Modules_congo.physicssprite_PhysicsSprite.html">PhysicsSprite</a>, <a href="Modules_congo.textlabel_TextLabel.html">TextLabel</a></li>
				</ul>
			</td>
		</tr>
	

	

	
	
	
	
	

	

	
	
								
		<tr>
			<td class="span1 name">Constructors:</td>
			<td>
				<ul class="unstyled">
					
						<li><a href='#New'>New</a> ()</li>
					
						<li><a href='#New(2)'>New</a> ( myImg:Image )</li>
					
						<li><a href='#New(3)'>New</a> ( tpimg:Image, dataName:String, imageName:String )</li>
					
				</ul>
			</td>
		</tr>
	
	
								
		<tr>
			<td class="span1 name">Properties:</td>
			<td>
				<ul class="unstyled">
					
						<li><a href='#BoundingBoxHeightScale'>BoundingBoxHeightScale</a> : Float ()</li>
					
						<li><a href='#BoundingBoxHeightScale(2)'>BoundingBoxHeightScale</a> : Void ( scale:Float )</li>
					
						<li><a href='#BoundingBoxWidthScale'>BoundingBoxWidthScale</a> : Float ()</li>
					
						<li><a href='#BoundingBoxWidthScale(2)'>BoundingBoxWidthScale</a> : Void ( scale:Float )</li>
					
						<li><a href='#CollisionsDisabled'>CollisionsDisabled</a> : Bool ()</li>
					
						<li><a href='#DisableCollisions'>DisableCollisions</a> : Void ( state:Bool=true )</li>
					
						<li><a href='#ImageHeight'>ImageHeight</a> : Float ()</li>
					
						<li><a href='#ImageWidth'>ImageWidth</a> : Float ()</li>
					
						<li><a href='#TransformationMatrix'>TransformationMatrix</a> : Float[] ()</li>
					
				</ul>
			</td>
		</tr>
	
	
								
		<tr>
			<td class="span1 name">Methods:</td>
			<td>
				<ul class="unstyled">
					
						<li><a href='Modules_congo.sprite_Sprite.html#BoundingBoxHeight'>BoundingBoxHeight</a> : Float ()</li>
					
						<li><a href='Modules_congo.sprite_Sprite.html#BoundingBoxWidth'>BoundingBoxWidth</a> : Float ()</li>
					
						<li><a href='Modules_congo.sprite_Sprite.html#DrawBoundingRect'>DrawBoundingRect</a> : Void ()</li>
					
						<li><a href='Modules_congo.sprite_Sprite.html#DrawGlobalBoundingRect'>DrawGlobalBoundingRect</a> : Void ()</li>
					
						<li><a href='Modules_congo.sprite_Sprite.html#GetBoundingRect'>GetBoundingRect</a> : Rect ()</li>
					
						<li><a href='Modules_congo.sprite_Sprite.html#GetCurrentImage'>GetCurrentImage</a> : Image ()</li>
					
						<li><a href='Modules_congo.sprite_Sprite.html#InitResScaler'>InitResScaler</a> : Void ( autoDetect:Bool=true, scale:Float=1.0 )</li>
					
						<li><a href='Modules_congo.sprite_Sprite.html#LoadFromTP'>LoadFromTP</a> : Bool ( tpimg:Image, dataName:String, imageName:String )</li>
					
						<li><a href='Modules_congo.sprite_Sprite.html#PaintItem'>PaintItem</a> : Void ()</li>
					
						<li><a href='Modules_congo.sprite_Sprite.html#SetMainImage'>SetMainImage</a> : Void ( img:Image )</li>
					
						<li><a href='Modules_congo.sprite_Sprite.html#Update'>Update</a> : Void ( dT:Int )</li>
					
				</ul>
			</td>
		</tr>
	

	
	
								
		<tr>
			<td class="span1 name">Inherited Properties:</td>
			<td>
				<ul class="unstyled">
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#Actions'>Actions</a> : List&lt;Action&gt; ()</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#Angle'>Angle</a> : Float ()</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#Angle(2)'>Angle</a> : Void ( rot:Float )</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#Children'>Children</a> : DisplayItem[] ()</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#CustomFlag'>CustomFlag</a> : Bool ()</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#CustomFlag(2)'>CustomFlag</a> : Void ( state:Bool )</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#CustomId'>CustomId</a> : Int ()</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#CustomId(2)'>CustomId</a> : Void ( value:Int )</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#CustomItemRef'>CustomItemRef</a> : DisplayItem ()</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#CustomItemRef(2)'>CustomItemRef</a> : Void ( item:DisplayItem )</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#CustomName'>CustomName</a> : String ()</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#CustomName(2)'>CustomName</a> : Void ( name:String )</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#DirtyZOrder'>DirtyZOrder</a> : Bool ()</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#Handle'>Handle</a> : Point ()</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#Hidden'>Hidden</a> : Bool ()</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#Hidden(2)'>Hidden</a> : Void ( state:Bool )</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#NumChildren'>NumChildren</a> : Int ()</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#Opacity'>Opacity</a> : Float ()</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#Parent'>Parent</a> : DisplayItem ()</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#Position'>Position</a> : Void ( pos:Point )</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#Position(2)'>Position</a> : Point ()</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#ResScaler'>ResScaler</a> : Float ()</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#ResScaler(2)'>ResScaler</a> : Void ( rscale:Float )</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#SetAngle'>SetAngle</a> : Void ( rot:Float )</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#UseLazySort'>UseLazySort</a> : Bool ()</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#XScale'>XScale</a> : Float ()</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#XScale(2)'>XScale</a> : Void ( scale:Float )</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#YScale'>YScale</a> : Float ()</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#YScale(2)'>YScale</a> : Void ( scale:Float )</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#ZOrder'>ZOrder</a> : Float ()</li>
					
				</ul>
			</td>
		</tr>
	
	
								
		<tr>
			<td class="span1 name">Inherited Methods:</td>
			<td>
				<ul class="unstyled">
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#ActionCompleted'>ActionCompleted</a> : Void ( actionId:Int )</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#AddChild'>AddChild</a> : Void ( child:DisplayItem )</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#AddChildWithZOrder'>AddChildWithZOrder</a> : Void ( child:DisplayItem, zOrder:Float=0.0 )</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#ButtonActivated'>ButtonActivated</a> : Void ( button:Sprite )</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#Draw'>Draw</a> : Void ()</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#FullSortZOrder'>FullSortZOrder</a> : Void ()</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#GetChildByCustomName'>GetChildByCustomName</a> : DisplayItem ( customName:String )</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#HasChild'>HasChild</a> : Bool ( ditem:DisplayItem )</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#RecursiveChildList'>RecursiveChildList</a> : List&lt;DisplayItem&gt; ()</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#RemoveAllActions'>RemoveAllActions</a> : Void ()</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#RemoveAllChildren'>RemoveAllChildren</a> : Void ()</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#RemoveChild'>RemoveChild</a> : Void ( child:DisplayItem )</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#ReorderChild'>ReorderChild</a> : Void ( child:DisplayItem, z:Float )</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#RunAction'>RunAction</a> : Void ( action:Action )</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#SendChildToBack'>SendChildToBack</a> : Void ( child:DisplayItem )</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#SendChildToFront'>SendChildToFront</a> : Void ( child:DisplayItem )</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#SetHandle'>SetHandle</a> : Void ( xpos:Float, ypos:Float, adjustForResScale:Bool=false )</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#SetHidden'>SetHidden</a> : Void ( state:Bool=true )</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#SetOpacity'>SetOpacity</a> : Void ( alphaLevel:Float, andChildren:Bool=true )</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#SetPosition'>SetPosition</a> : Void ( pos:Point )</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#SetPosition(2)'>SetPosition</a> : Void ( xpos:Float, ypos:Float )</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#SetScale'>SetScale</a> : Void ( scale:Float )</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#SetScale(2)'>SetScale</a> : Void ( xscl:Float, yscl:Float )</li>
					
						<li><a href='Modules_congo.displayitem_DisplayItem.html#UpdateChildren'>UpdateChildren</a> : Void ( dT:Int )</li>
					
				</ul>
			</td>
		</tr>
	
	
	
	
</table>


	<a name="description"></a>
	<h2>Detailed Discussion</h2>
	Main sprite class. Can load atlas/spritesheets, import from TexturePacker.
Since it is derived from DisplayItem, it can own child items and run actions.
<p>
Uses TextureCache to store it's Images.
<p>
See also AnimatedSprite, for frame-based animation.
<p>
Todo: remove child fns?
	
	
	<hr>






						
	<h2>Constructor Documentation</h2>
	<div class="scope-members-list">
		
			<div class="item">
				<a name='New'></a>
				<div class="well well-small name"><b>Method New ()</b></div>
				<div class="description">
					<p>	Default constr. No images are added, but can be added later using SetMainImage.</p>
					
					
				</div>
			</div>
		
			<div class="item">
				<a name='New(2)'></a>
				<div class="well well-small name"><b>Method New ( myImg:<a href="Modules_mojo.graphics_Image.html">Image</a> )</b></div>
				<div class="description">
					<p>	Creates a Sprite with a single image. See also CongoResourceLoader (in DisplayUtils) to load an Image.
	You can set Image.MidHandle on the image as required.</p>
					
					
				</div>
			</div>
		
			<div class="item">
				<a name='New(3)'></a>
				<div class="well well-small name"><b>Method New ( tpimg:<a href="Modules_mojo.graphics_Image.html">Image</a>, dataName:String, imageName:String )</b></div>
				<div class="description">
					<p>	Creates a Sprite from a Texturepacker file. See LoadFromTP for more information.</p>
					
					
				</div>
			</div>
		
	</div>
	<hr>


						
	<h2>Property Documentation</h2>
	<div class="scope-members-list">
		
			<div class="item">
				<a name='BoundingBoxHeightScale'></a>
				<div class="well well-small name"><b>Method BoundingBoxHeightScale : Float () Property</b></div>
				<div class="description">
					<p>	Returns the Bounding box height scale factor, default 1.0. Used by CollisionLayer.</p>
					
					
				</div>
			</div>
		
			<div class="item">
				<a name='BoundingBoxHeightScale(2)'></a>
				<div class="well well-small name"><b>Method BoundingBoxHeightScale : Void ( scale:Float ) Property</b></div>
				<div class="description">
					<p>	Sets the Bounding box height scale factor, default 1.0. Used by CollisionLayer.</p>
					
					
				</div>
			</div>
		
			<div class="item">
				<a name='BoundingBoxWidthScale'></a>
				<div class="well well-small name"><b>Method BoundingBoxWidthScale : Float () Property</b></div>
				<div class="description">
					<p>	Returns the Bounding box width scale factor, default 1.0. Used by CollisionLayer.</p>
					
					
				</div>
			</div>
		
			<div class="item">
				<a name='BoundingBoxWidthScale(2)'></a>
				<div class="well well-small name"><b>Method BoundingBoxWidthScale : Void ( scale:Float ) Property</b></div>
				<div class="description">
					<p>	Sets the Bounding box width scale factor, default 1.0. Used by CollisionLayer.</p>
					
					
				</div>
			</div>
		
			<div class="item">
				<a name='CollisionsDisabled'></a>
				<div class="well well-small name"><b>Method CollisionsDisabled : Bool () Property</b></div>
				<div class="description">
					<p>	Returns the status of the collision detection flag for this Sprite. Used in CollisionLayer (or use for your own
	purposes).</p>
					
					
				</div>
			</div>
		
			<div class="item">
				<a name='DisableCollisions'></a>
				<div class="well well-small name"><b>Method DisableCollisions : Void ( state:Bool=true ) Property</b></div>
				<div class="description">
					<p>	Set this flag to remove the Sprite from any collision detection performed in a CollisionLayer (or use for your own
	purposes).</p>
					
					
				</div>
			</div>
		
			<div class="item">
				<a name='ImageHeight'></a>
				<div class="well well-small name"><b>Method ImageHeight : Float () Property</b></div>
				<div class="description">
					<p>	Returns the current Image height (original, non-scaled), or 0 if no current image.</p>
					
					
				</div>
			</div>
		
			<div class="item">
				<a name='ImageWidth'></a>
				<div class="well well-small name"><b>Method ImageWidth : Float () Property</b></div>
				<div class="description">
					<p>	Returns the current Image width (original, non-scaled), or 0 if no current image.</p>
					
					
				</div>
			</div>
		
			<div class="item">
				<a name='TransformationMatrix'></a>
				<div class="well well-small name"><b>Method TransformationMatrix : Float[] () Property</b></div>
				<div class="description">
					<p>	For advanced use. Returns the Sprite's current transform matrix (6 float array). 
	You may need this for custom Draw code. Note, this data only gets set in the Draw step.</p>
					
					
				</div>
			</div>
		
	</div>
	<hr>


						
	<h2>Method Documentation</h2>
	<div class="scope-members-list">
		
			<div class="item">
				<a name='BoundingBoxHeight'></a>
				<div class="well well-small name"><b>Method BoundingBoxHeight : Float ()</b></div>
				<div class="description">
					<p>	Returns the bounding box height. Used by CollisionLayer.
	By default this is the same as the current ImageHeight (adjusted for sd/hd/xhd res scalefactor), 
	and also scaled by the user-defined boundingBoxHeightScale. Local, not global coords.</p>
					
					
				</div>
			</div>
		
			<div class="item">
				<a name='BoundingBoxWidth'></a>
				<div class="well well-small name"><b>Method BoundingBoxWidth : Float ()</b></div>
				<div class="description">
					<p>	Returns the bounding box width. Used by CollisionLayer.
	By default this is the same as the current ImageHeight (adjusted for sd/hd/xhd res scalefactor), 
	and also scaled by the user-defined boundingBoxHeightScale. Local, not global coords.</p>
					
					
				</div>
			</div>
		
			<div class="item">
				<a name='DrawBoundingRect'></a>
				<div class="well well-small name"><b>Method DrawBoundingRect : Void ()</b></div>
				<div class="description">
					<p>	For debugging purposes, draws the bounding rect (local coords). Color is based on bounding rect size.</p>
					
					
				</div>
			</div>
		
			<div class="item">
				<a name='DrawGlobalBoundingRect'></a>
				<div class="well well-small name"><b>Method DrawGlobalBoundingRect : Void ()</b></div>
				<div class="description">
					<p>	Experimental, not for use yet. 
	Draws the bounding rect using the cached global transform. Color is based on bounding rect size.</p>
					
					
				</div>
			</div>
		
			<div class="item">
				<a name='GetBoundingRect'></a>
				<div class="well well-small name"><b>Method GetBoundingRect : <a href="Modules_congo.rect_Rect.html">Rect</a> ()</b></div>
				<div class="description">
					<p>	Returns the bounding rect in local coordinates. Used by CollisionLayer hit detection. 
	The box size can be customised (e.g. reduced or expanded beyond usual Image size) by overriding
	BoundingBoxHeight or BoundingBoxWidth.
	
	Known issues: doesn't deal with non-centre rotation handles.</p>
					
					
				</div>
			</div>
		
			<div class="item">
				<a name='GetCurrentImage'></a>
				<div class="well well-small name"><b>Method GetCurrentImage : <a href="Modules_mojo.graphics_Image.html">Image</a> ()</b></div>
				<div class="description">
					<p>	Returns the current main Image (could be Null if not set).</p>
					
					
				</div>
			</div>
		
			<div class="item">
				<a name='InitResScaler'></a>
				<div class="well well-small name"><b>Method InitResScaler : Void ( autoDetect:Bool=true, scale:Float=1.0 )</b></div>
				<div class="description">
					<p>	Internal. Sets res scale factor based on display settings. i.e. if the display is set-up for
	hd images then the res scale will be set to 2.0 to double the base size.
	This is called automatically from the constr, or when the main image is changed, you don't usually
	need to do this manually.</p>
					
					
				</div>
			</div>
		
			<div class="item">
				<a name='LoadFromTP'></a>
				<div class="well well-small name"><b>Method LoadFromTP : Bool ( tpimg:<a href="Modules_mojo.graphics_Image.html">Image</a>, dataName:String, imageName:String )</b></div>
				<div class="description">
					<p>	Loads Image from Texturepacker file (Generic xml format). Can be called on a current Sprite,
	or more usually, called from the constructor on creation of the Sprite.
<p>
	Will throw exception if image atlas is invalid. 
	This method uses TextureCache for future requests for the same image resource.
<p>
	Important! Do <b>NOT</b> use Image.MidHandle on the sprite sheet, the frames will be centered automatically.
<p>
	Note, don't supply 'hd' or other extension names for the xml <b>or</b> the image names, this routine will add them.
	All names are case-sensitive.</p>
					
					
				</div>
			</div>
		
			<div class="item">
				<a name='PaintItem'></a>
				<div class="well well-small name"><b>Method PaintItem : Void ()</b></div>
				<div class="description">
					<p>	All DisplayItems must implement the base class PaintItem method.</p>
					
					
				</div>
			</div>
		
			<div class="item">
				<a name='SetMainImage'></a>
				<div class="well well-small name"><b>Method SetMainImage : Void ( img:<a href="Modules_mojo.graphics_Image.html">Image</a> )</b></div>
				<div class="description">
					<p>	Manually change the Image associated with the Sprite.</p>
					
					
				</div>
			</div>
		
			<div class="item">
				<a name='Update'></a>
				<div class="well well-small name"><b>Method Update : Void ( dT:Int )</b></div>
				<div class="description">
					<p>	Main Update. Derived classes can override this, remember to call Super.Update()!</p>
					
					
				</div>
			</div>
		
	</div>
	<hr>




				
			</div>
		</div>
	</div>
</body>
</html>